package com.sonny.test.xalan;


import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;

public class XalanTest1 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		TransformerFactory tFactory = TransformerFactory.newInstance();
				
//		String fileXML_1="./testfiles/foo.xml";
//		String fileXSL_1="./testfiles/foo.xsl";
//		String fileOUTPUT_1="./testfiles/foo.out";

		String fileXML_1="./testfiles/birds.xml";
		String fileXSL_1="./testfiles/birds.xsl";
		String fileOUTPUT="./testfiles/birds.out";
		
		Transformer transformer;
		try {
			transformer = tFactory.newTransformer(new StreamSource(fileXSL_1));
			transformer.setParameter("param1",	"parameter #1");
			transformer.setParameter("param2",	"parameter #2");
			transformer.transform(new StreamSource(fileXML_1), new StreamResult(new FileOutputStream(fileOUTPUT)));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (TransformerException e) {
			e.printStackTrace();
		}
		
		System.out.println("*** The result is in "+fileOUTPUT+" ***");

	}

}
